import request from '@/utils/request'

const apis = {
    COURSE_INFO: '/course/getcourse',
    EXAM_INFO: '/course/getexamination',
    START_EXAM: '/course/startexamination',
    QUESTION_LIST: '/course/getquestionlist',
    SUBMIT: '/course/finishexamination',
    COMPARE_FACE: '/remoteapi/compareface'
}

export default {
    
    // 信息列表
    getCourseInfo(data) {
        let dt = data || {};
        return request.post(apis.COURSE_INFO, dt.params, {
            headers: dt.headers || {}
        });
    },

    getExamInfo(data) {
        let dt = data || {};
        return request.post(apis.EXAM_INFO, dt.params, {
            headers: dt.headers || {}
        });
    },

    startExam(data) {
        let dt = data || {};
        return request.post(apis.START_EXAM, dt.params, {
            headers: dt.headers || {}
        });
    },

    getQuestionList(data) {
        let dt = data || {};
        return request.post(apis.QUESTION_LIST, dt.params, {
            headers: dt.headers || {}
        });
    },

    submit(data) {
        let dt = data || {};
        return request.post(apis.SUBMIT, dt.params, {
            headers: dt.headers || {}
        });
    },

    compareFace(data) {
        let dt = data || {};
        let params = dt.params || {};
        let formData = new FormData();
        for (let k in params) {
            if (k && params[k] != null) {
                formData.append(k + '', params[k]);
            }
        }

        return request.post(apis.COMPARE_FACE, formData, {
            headers: Object.assign({
                'Content-Type': 'multipart/form-data'
            }, dt.headers)
        });
    }
}